cmake_minimum_required(VERSION 3.10)
project(dual_camera_system VERSION 1.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 编译选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O2  -Wno-error=narrowing -w")

# 查找依赖
find_library(SYSTEMD_LIB systemd)
if(NOT SYSTEMD_LIB)
    message(FATAL_ERROR "systemd library not found")
endif()

# 包含公共目录
include_directories(common)
SET(LIB_LIST
libpthread.so
${SYSTEMD_LIB}
)
# 收集公共源文件
set(COMMON_SOURCES
    common/ipc.cpp
)

# 编译采集进程
add_executable(dual_cam_capture
    src/capture.cpp
    ${COMMON_SOURCES}
)
target_link_libraries(dual_cam_capture  ${LIB_LIST})
# 编译算法进程
add_executable(dual_cam_algo
    src/algo.cpp
    ${COMMON_SOURCES}
)
target_link_libraries(dual_cam_algo  ${LIB_LIST})
# 编译监管进程
add_executable(dual_cam_supervisor
    src/supervisor.cpp
    ${COMMON_SOURCES}
)
target_link_libraries(dual_cam_supervisor  ${LIB_LIST})

# 安装配置
install(TARGETS dual_cam_capture dual_cam_algo dual_cam_supervisor
    RUNTIME DESTINATION /usr/local/bin
)

# 安装systemd服务文件
install(FILES
    systemd/dual-cam-capture.service
    systemd/dual-cam-algo.service
    systemd/dual-cam-supervisor.service
    systemd/dual-cam.target
    DESTINATION /etc/systemd/system
)